﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using _TablesManagement;

namespace _TablesManagement
{

    public partial class Table : UserControl
    {
        public enum TableStatus
        {
            Available = 1, Reserved, Waiting, Occupied, Dirty, Cleaning
        }

        private TableStatus status;       

        public Table()
        {
            InitializeComponent();
            Status = TableStatus.Available;
        }

        public string TableName { get { return lblName.Text; } set { lblName.Text = value; } }

        delegate void SetpicStatusDeg(DevExpress.XtraEditors.PictureEdit picStatus, TableStatus status);

        private void SetpicStatus(DevExpress.XtraEditors.PictureEdit picStatus, TableStatus status)
        {
            //select a status picture for table
            picStatus.Image = (Image)MapResource.ResourceManager.GetObject("img" + status);
            //picStatus.Image = MapResource.imgAvailable;
            picStatus.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Stretch;
        }
        public TableStatus Status
        {
            get { return status; }
            set
            {
                status = value;

                if (!picStatus.InvokeRequired)
                {
                    //select a status picture for table
                    picStatus.Image = (Image)MapResource.ResourceManager.GetObject("img" + status);
                    //picStatus.Image = MapResource.imgAvailable;
                    picStatus.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Stretch;
                }
                else
                {
                    SetpicStatusDeg d = new SetpicStatusDeg(SetpicStatus);
                    picStatus.Invoke(d, new object[] { picStatus, status });
                }
            }
        }

    }
}
